package Task2;

public class EmailSender implements Runnable {
	private Queue queue;
	private boolean stop;

	public EmailSender(Queue queue) {
		this.queue = queue;
	}

	public synchronized void stopWork() {
		stop = true;
	}

	public void run() {
		while (!stop) {
			System.out.println("Notification email for "
					+ queue.getEmails().get(0).getClient().getName()
					+ " was sent");
			queue.removeEmail();
		}
	}
}
